import 'package:flutter/material.dart';

class AnimatedContainerView extends StatefulWidget {
  const AnimatedContainerView({super.key});
  @override
  State<AnimatedContainerView> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<AnimatedContainerView> {
  bool flag = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.animation),
        onPressed: () {
          setState(() {
            flag = !flag;
          });
        },
      ),
      appBar: AppBar(
        title: const Text("AnimatedContainer Demo"),
      ),
      body: Center(
        child: AnimatedContainer(
          duration: const Duration(milliseconds: 500), // 动画时长500 ms
          width: flag ? 100 : 300,
          height: flag ? 100 : 300,
          color: Colors.blue,
        ),
      ),
    );
  }
}
